package jsu.xxy.coffee3.controller;




import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import jsu.xxy.coffee3.Utils.MD5;
import jsu.xxy.coffee3.domain.*;
import jsu.xxy.coffee3.mapper.RegisterRequestMapper;
import jsu.xxy.coffee3.mapper.StaffsMapper;
import jsu.xxy.coffee3.service.StaffsService;
import jsu.xxy.coffee3.service.impl.RegisterRequestServiceImpl;
import jsu.xxy.coffee3.service.impl.StaffsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/registerRequest")
public class RegisterRequestController {
    @Autowired
    RegisterRequestMapper registerRequestMapper;
    @Autowired
    RegisterRequestServiceImpl registerRequestService;
    @Autowired
    StaffsMapper staffsMapper;
    @Autowired
    StaffsServiceImpl service;
    @PostMapping("/sign")
    @Operation(summary = "员工注册")
    public Boolean sign(@RequestBody RegisterNoId registerNoId){
        return service.sign(registerNoId);
    }
    @GetMapping("/getAll")
    @Operation(summary = "查所有申请注册")
    public Page<RegisterRequest> getAllInform(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
                                              @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize)
    {

        return registerRequestService.getAllInform(pageNo,pageSize);

    }
    @PostMapping("/agree/{phone}")
    @Operation(summary = "同意申请成为员工")
    public Boolean agreeEmployee( @PathVariable String phone)
    {
        return registerRequestService.agreeEmployee(phone);


    }
    @DeleteMapping("/disagree/{phone}")
    @Operation(summary = "拒绝申请成为员工")
    public Boolean disagreeEmployee( @PathVariable String phone)
    {
        return registerRequestService.disagreeEmployee(phone);

    }
    @PostMapping("/agreeList/{phones}")
    @Operation(summary = "批量同意申请成为员工")
    public Integer agreeEmployeeList( @PathVariable List<String> phones)
    {
        return registerRequestService.agreeEmployeeList(phones);


    }
}
